from flask import Flask
import json
import os

app = Flask(__name__, static_folder="static", static_url_path="/static")

'''
Baidu Map
'''
@app.route("/")
def main():
    return app.send_static_file("map.html")

'''
Send transmission line and tower point data to browser
'''
@app.route("/data")
def getData():
    with open(
        os.path.join(os.path.split(os.path.realpath(__file__))[0], "data", "data.json"), 
        "r"
    ) as data_file:
        data = json.load(data_file)
        return json.dumps(data, ensure_ascii=False)

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8000, debug=True)